package com.hylanda.util;

import java.net.URLDecoder;
import java.net.URLEncoder;

/** 
 * @author zhangy
 * @E-mail:blackoon88@gmail.com 
 * @qq:846579287
 * @version created at：2018年3月15日 上午10:52:58 
 * note
 */
public class URLHelper {
	public static String decode(String url){
		if(url==null)
			return null;
		try {
//			url = url.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
//			url = url.replaceAll("\\+", "%2B");
			url=URLDecoder.decode(url,"UTF-8");
		} catch (Exception e) {
		}
		return url;
	}
	
	public static String encode(String url){
		if(url==null)
			return null;
		try {
			url=URLEncoder.encode(url,"UTF-8");
		} catch (Exception e) {
		}
		return url;
	}
	public static void main(String[] args){
		System.out.print("1"+decode("%2520")+"1");
	}
}
